<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>修改信息</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="shortcut icon" type="image/x-icon" href="https://wwl.ycws.cc/image/backgroundimage/e.ico">
	<style type="text/css">
		#preview1{width:170px;height:190px;border:1px solid #000;overflow:hidden; text-align: center;}
		#preview2{width:170px;height:190px;border:1px solid #000;overflow:hidden; text-align:center;}
		#preview3{width:170px;height:190px;border:1px solid #000;overflow:hidden; text-align:center;}
		#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
	</style>
	<script src="js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
		 function previewImage1(file){
        	var cutout=document.getElementById('filepath1').value;	//获取文件路径
        	var newCutout=cutout.substring(cutout.indexOf('.'));	//判断后缀名是否为图片
        	var jpg='.jpg',png='.png',jpeg='.jpeg',gif='.gif';
        	if(jpg == newCutout || png == newCutout || jpeg == newCutout || gif == newCutout){
	        	var MAXWIDTH  = 260; 
	          	var MAXHEIGHT = 180;
	          	var div = document.getElementById('preview1');
          	if (file.files && file.files[0]){
	            div.innerHTML ='<img id=imghead1>';
	            var img = document.getElementById('imghead1');
	            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                img.style.marginTop = rect.top+'px';
           	}
	            var reader = new FileReader();
	            reader.onload = function(evt){img.src = evt.target.result;}
	            reader.readAsDataURL(file.files[0]);
          	}else{//兼容IE
	            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
	            file.select();
	            var src = document.selection.createRange().text;
	            div.innerHTML = '<img id=imghead>';
	            var img = document.getElementById('imghead');
	            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
	            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
	            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
	            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          	}	
        	}else{
        		alert('上传的不是图片,请重新上传');
        	} 
        }
        
        function previewImage2(file){
        	var cutout=document.getElementById('filepath2').value;	//获取文件路径
        	var newCutout=cutout.substring(cutout.indexOf('.'));	//判断后缀名是否为图片
        	var jpg='.jpg',png='.png',jpeg='.jpeg',gif='.gif';
        	if(jpg == newCutout || png == newCutout || jpeg == newCutout || gif == newCutout){
	        	var MAXWIDTH  = 260; 
	          	var MAXHEIGHT = 180;
	          	var div = document.getElementById('preview2');
          	if (file.files && file.files[0]){
	            div.innerHTML ='<img id=imghead2>';
	            var img = document.getElementById('imghead2');
	            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                img.style.marginTop = rect.top+'px';
           	}
	            var reader = new FileReader();
	            reader.onload = function(evt){img.src = evt.target.result;}
	            reader.readAsDataURL(file.files[0]);
          	}else{//兼容IE
	            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
	            file.select();
	            var src = document.selection.createRange().text;
	            div.innerHTML = '<img id=imghead>';
	            var img = document.getElementById('imghead');
	            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
	            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
	            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
	            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          	}	
        	}else{
        		alert('上传的不是图片,请重新上传');
        	} 
        }
        
        function previewImage3(file){
        	var cutout=document.getElementById('filepath3').value;	//获取文件路径
        	var newCutout=cutout.substring(cutout.indexOf('.'));	//判断后缀名是否为图片
        	var jpg='.jpg',png='.png',jpeg='.jpeg',gif='.gif';
        	if(jpg == newCutout || png == newCutout || jpeg == newCutout || gif == newCutout){
	        	var MAXWIDTH  = 260; 
	          	var MAXHEIGHT = 180;
	          	var div = document.getElementById('preview3');
          	if (file.files && file.files[0]){
	            div.innerHTML ='<img id=imghead3>';
	            var img = document.getElementById('imghead3');
	            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                img.style.marginTop = rect.top+'px';
           	}
	            var reader = new FileReader();
	            reader.onload = function(evt){img.src = evt.target.result;}
	            reader.readAsDataURL(file.files[0]);
          	}else{//兼容IE
	            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
	            file.select();
	            var src = document.selection.createRange().text;
	            div.innerHTML = '<img id=imghead>';
	            var img = document.getElementById('imghead');
	            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
	            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
	            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
	            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
          	}	
        	}else{
        		alert('上传的不是图片,请重新上传');
        	} 
        }
        
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight ){
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                if( rateWidth > rateHeight ){
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else{
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }
	</script>
	
	<script type="text/javascript">
		$(document).ready(function(){
			$("#add").click(function(){
				var reg=/^1[3|5|7|8]\d{9}$/;
				var yname=$("#yname").val();
				var ysex=$("#ysex").val();
				var yphone=$("#yphone").val();
				var ydetailed=$("#ydetailed").val();
				//判断修改要求
		 		if(yname == ""){
					alert("姓名不能为空");
				}else if(ysex == ""){
					alert("性别不能为空");
				}else if(!reg.test(yphone)){
					alert("手机号码不符");
				}else if(ydetailed == ""){
					alert("单元楼不能为空");
				}else{
					$("#addform").submit();
				}
			});
		});
	</script>
  </head>
  <body>
	<table align="center" border="0">
	<tr>
		<td><img alt="" src="<%=path%>/images/eanquan.jpg" width="150px" height="100px"></td>
		<td width="200" align="center"><font style="font-size: 30px; text-align: right; margin-top: 30px;">修改信息</font></td>
	</tr>
	</table>
	
	<hr/>
	<div align="center">
	<div>
	 	<c:if test="${result==1}">
	<div style="padding-top:5px; ">
	<form id="addform" action="<%=path%>/pc/update_id" method="post" enctype="multipart/form-data">
	<table border="0"  cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td colspan="3" align="left"><input type="hidden" name="yid" value="${uploads.yid}" style="width: 270px; height: 30px;"/></td>
	</tr>
	<tr>
		<td align="center"><div id="preview1"><img alt="" src="${uploads.yfilename}" id="imghead1" width="150" height="200"></div></td>
		<td align="center"><div id="preview2"><img alt="" src="${uploads.yfilename1}" id="imghead2" width="150" height="200"></div></td>
		<td align="center"><div id="preview3"><img alt="" src="${uploads.yfilename2}" id="imghead3" width="150" height="200"></div></td>
	</tr>
	<tr>
		<td height="70" width="160px;" align="center">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</td>
		<td colspan="2" align="left"><input type="text" name="yname" id="yname" value="${uploads.yname}" style="width: 270px; height: 30px;"/></td>
	</tr>
	<tr>
		<td height="70" align="center">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:</td>
		<td colspan="2" align="left"><input type="text" name="ysex" id="ysex" value="${uploads.ysex}" style="width: 270px; height: 30px;"/></td>
	</tr>
	<tr>
		<td colspan="3" align="left"><input type="hidden" name="yowner" value="${uploads.yowner}" style="width: 270px; height: 30px;"/></td>
	</tr> 
	<tr>
		<td height="70" align="center">手机&nbsp;&nbsp;号码:</td>
		<td  colspan="2" align="left"><input type="text" name="yphone" id="yphone" value="${uploads.yphone}"  style="width:270px; height:30px;" /></td>
	</tr>    
	<tr>
		<td  colspan="3" align="left"><input type="hidden" name="yaddress" value="${uploads.yaddress}"  style="width:270px; height:30px;" /></td>
	</tr>    		
	<tr>
		<td height="70" align="center">单元/楼/室:</td>
		<td  colspan="2" align="left"><input type="text" name="ydetailed" id="ydetailed" value="${uploads.ydetailed}" style="width:270px; height:30px;"/></td>
	</tr>
	<tr>
		<td  colspan="3" align="left"><input type="hidden" name="yindex" value="${uploads.yindex}" style="width:270px; height:30px;"/></td>
	</tr>
	<tr>
		<td  colspan="3" align="left"><input type="hidden" name="createtime" value="${uploads.createtime}" style="width:270px; height:30px;"/></td>
	</tr>
	<tr>
		<td  colspan="3" align="left"><input type="hidden" name="updatetime" value="${uploads.updatetime}" style="width:270px; height:30px;"/></td>
	</tr>
	<tr align="center">
		<td colspan="3" height="70px;"><input type="button" id="add" value="修改" style="width: 500px; height: 40px; background-color: #44BB44; color: white; font-size: 20px;"/></td>
	</tr>
	</table>	
	</form>
	</div>
	<hr/>
	</c:if>
	</div>
	</div>
	<c:if test="${empty result}">
	<a href="login.jsp">请登录</a>
	</c:if>
	</body>
</html>
